package datasrv

import (
	"chatgpt/helper/code"
	"chatgpt/logq"
	"chatgpt/plugin/rpcx"
	"chatgpt/services/datasrv/sqlhelper"
	"context"
)

type SystemApi struct {
}

func (self *SystemApi) UserGptSelect(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("SystemApi")
	err := client.Call(ctx, "UserGptSelect", req, res)
	if err != nil {
		logq.Error("DataSrv.UserGpt.Select err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *SystemApi) UserGptSave(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("SystemApi")
	err := client.Call(ctx, "UserGptSave", req, res)
	if err != nil {
		logq.Error("DataSrv.UserGpt.Save err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *SystemApi) UserGptTotal(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("SystemApi")
	err := client.Call(ctx, "UserGptTotal", req, res)
	if err != nil {
		logq.Error("DataSrv.UserGpt.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *SystemApi) UserGptFirst(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("SystemApi")
	err := client.Call(ctx, "UserGptFirst", req, res)
	if err != nil {
		logq.Error("DataSrv.UserGpt.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *SystemApi) UserGptDelete(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("SystemApi")
	err := client.Call(ctx, "UserGptDelete", req, res)
	if err != nil {
		logq.Error("DataSrv.UserGpt.Delete err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}
